<?php
/**
 * Created by PhpStorm.
 * User: yu
 * Date: 2017/1/5
 * Time: 下午5:12
 */

namespace Admin\Controller;


use Common\Controller\AdminController;
use Common\Model\TypeModel;
use Think\Page;

class TypeController extends AdminController
{
	protected $typeModel;
	public function __init(){
		parent::__init();
		$this->typeModel = new TypeModel();
	}
	public function lists(){
		//获得总条数
		$count = $this->typeModel->count();
		//分页
		$page = new Page($count,1);
		$page->setConfig('theme',"<ul class='pagination'></li><li>%FIRST%</li><li>%UP_PAGE%</li><li>%LINK_PAGE%</li><li>%DOWN_PAGE%</li><li>%END%</li><li><a> %HEADER%  %NOW_PAGE%/%TOTAL_PAGE% 页</a></ul>");
//		获得页码
		$pageNum =  $page->show();
		//获得每页的数据
		$typeList = $this->typeModel->limit($page->firstRow.','.$page->listRows)->select();

		$this->assign('typeList',$typeList);//分配每页数据
		$this->assign('pageNum',$pageNum);
		$this->display();
	}
	public function addType(){
		if(IS_POST){
			$this->store($this->typeModel,I('post.'),function(){

			});

		}else{
			$this->display();
		}
	}
}